<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../三段/五月/jquery/jquery.js"></script>
</head>

<body>
    <div>
        <input type="checkbox" name=""><span>苹果-</span><span>10</span>
        <input type="number" value="1" min="1" name="shui">
    </div>
    <div>
        <input type="checkbox" name=""><span>香蕉-</span><span>16</span>
        <input type="number" value="1" min="1" name="shui">
    </div>
    <p>总价：<span></span></p>
    全选<input type="checkbox" id="quanxuan">
</body>
<script>
    $('div :checkbox,[name="shui"]').change(function(){
        var total = 0;
        $('div :checkbox').each(function(){
            if ($(this).prop('checked')) {
                var price = $(this).next().next().html()
                var num = $(this).next().next().next().val()
                total += (price * num)
            }
            $('span').last().html(total)
        })
    })
    $('#quanxuan').change(function(){
        $('div :checkbox').prop('checked',$(this).prop('checked'))
        $('div :checkbox').change()
    })
</script>

</html>